﻿<Table TItem="CustomDynamicColumnsObjectData" Items="CustomDynamicItems"
        IsStriped="true" IsBordered="true" ShowToolbar="true" ShowColumnList="true" ShowDefaultButtons="false" ShowRefresh="false">
    <TableColumns>
        <TableColumn @bind-Field="@context.Fix" Sortable="true" Filterable="true" />
        @foreach (var element in StaticColumnList)
        {
            <TableColumn Field="@element" FieldName="@element" Text="@element" Sortable="true" Filterable="true">
                <Template Context="v">
                    <div>Template - @v.Value</div>
                </Template>
            </TableColumn>
        }
    </TableColumns>
</Table>

@code {
    [NotNull]
    private IEnumerable<CustomDynamicColumnsObjectData>? CustomDynamicItems { get; set; }

    private static List<string> StaticColumnList => new() { "A", "B", "C", "Z" };

    /// <summary>
    /// OnInitialized
    /// </summary>
    protected override void OnInitialized()
    {
        base.OnInitialized();
        CustomDynamicItems = Enumerable.Range(1, 10).Select(index => new CustomDynamicColumnsObjectData(index.ToString(), StaticColumnList.ToDictionary(d => d, d => (object?)$"{d}{index}")));
    }
}
